package shiyan8_3;

public class DecideTree {
    protected BTNode r;
    protected String s;
    public DecideTree(){
        r=new BTNode("你喜欢裴湘瑞吗？");
        r.left=new BTNode("你是不是想叫他爸爸？");
        BTNode one=r.left;
        r.right=new BTNode("不，你想。");
        one.left=new BTNode("你是不是特别想叫他爸爸？");
        one.right=new BTNode("不，你特别想");
        BTNode two=one.left;
        two.left=new BTNode("优秀铁子");
        two.right=new BTNode("你挂了");
    }
    public void run(){
        System.out.println(r.element);
    }
    public int run(String a) {
        String str = a;
        switch (str) {
            case "y": {
                r = r.left;
                break;
            }
            case "n": {
                r = r.right;
                break;
            }
            default:
                System.out.println("illegal input");
        }
        if (r != null) {
            System.out.println(r.element);
            return 1;
        }
        else
            return -1;
    }
}
